package simulator.implementation.agent;
import javax.vecmath.Vector3d;

import simbad.sim.LightSensor;
import simbad.sim.RobotFactory;
import simulator.meta.agent.ControlledAgent;
public class LightRobot extends ControlledAgent{
	//Attributes:
	private LightSensor lightSensor;
	//Constructor: 
	public LightRobot(Vector3d position, String name) {
		super(position, name);
		this.step = 0;
		this.turn = 0;
		//Agregar un sensor de luz al agente:
		this.lightSensor = RobotFactory.addLightSensor(this);
	}
	//Methods:
	public void initBehavior() {}

	public void performBehavior() {
		this.setTranslationalVelocity(this.step);
		this.setRotationalVelocity((Math.PI/180)*this.turn);
		
		//Cada 10 tiempos del ambiente, se obtiene la medición:
		if((this.getCounter()%10)==0){
			/*
			 * Obtener medición del sensor:
			 * 0.0 significa que no hay luz;
			 * y 1.0 es máxima iluminación.
			 */
			float measure = this.lightSensor.getAverageLuminance();
			//Mostrar medición por consola:
			System.out.println("Light: "+measure+".");
		}
	}
}
